```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>享元设计模式：共享对象以减少内存消耗</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        .hero-bg {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
        }
        .feature-icon {
            color: #667eea;
            font-size: 2.5rem;
            margin-bottom: 1rem;
        }
        .dropdown:hover .dropdown-menu {
            display: block;
        }
        .code-block {
            background-color: #282c34;
            border-radius: 8px;
            padding: 1.5rem;
            font-family: 'Courier New', monospace;
            position: relative;
        }
        .code-header {
            background-color: #21252b;
            padding: 0.5rem 1rem;
            border-top-left-radius: 8px;
            border-top-right-radius: 8px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            color: #abb2bf;
            font-size: 0.9rem;
        }
        .code-copy-btn {
            background: none;
            border: none;
            color: #abb2bf;
            cursor: pointer;
            transition: color 0.3s;
        }
        .code-copy-btn:hover {
            color: #61afef;
        }
        .mermaid {
            background-color: white;
            padding: 2rem;
            border-radius: 8px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-bg text-white py-20">
        <div class="container mx-auto px-6">
            <div class="max-w-4xl mx-auto text-center">
                <h1 class="text-4xl md:text-5xl font-bold mb-6 font-serif">享元设计模式</h1>
                <p class="text-xl md:text-2xl mb-8">共享对象以减少内存消耗</p>
                <div class="w-24 h-1 bg-purple-300 mx-auto mb-8"></div>
                <p class="text-lg md:text-xl opacity-90 max-w-2xl mx-auto">
                    一种结构型设计模式，旨在减少内存消耗，通过共享对象来支持大量细粒度的对象。
                </p>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <div class="container mx-auto px-6 py-16 max-w-6xl">
        <!-- Features Section -->
        <section class="mb-20">
            <h2 class="text-3xl font-bold mb-12 text-center font-serif">关键特点</h2>
            <div class="grid md:grid-cols-2 gap-8">
                <div class="bg-white p-8 rounded-lg shadow-md card-hover">
                    <div class="text-center">
                        <i class="fas fa-object-group feature-icon"></i>
                        <h3 class="text-xl font-bold mb-4">共享对象</h3>
                    </div>
                    <p class="text-gray-700">享元模式将对象分为可共享的内部状态和不可共享的外部状态。内部状态是对象共享的部分，外部状态是对象特定的部分。</p>
                </div>
                <div class="bg-white p-8 rounded-lg shadow-md card-hover">
                    <div class="text-center">
                        <i class="fas fa-memory feature-icon"></i>
                        <h3 class="text-xl font-bold mb-4">减少内存消耗</h3>
                    </div>
                    <p class="text-gray-700">通过共享内部状态，可以减少系统中对象的数量，从而显著降低内存消耗，提升系统性能。</p>
                </div>
                <div class="bg-white p-8 rounded-lg shadow-md card-hover">
                    <div class="text-center">
                        <i class="fas fa-industry feature-icon"></i>
                        <h3 class="text-xl font-bold mb-4">共享管理</h3>
                    </div>
                    <p class="text-gray-700">享元工厂负责维护已创建的享元对象，确保共享对象的重复利用，有效管理系统资源。</p>
                </div>
                <div class="bg-white p-8 rounded-lg shadow-md card-hover">
                    <div class="text-center">
                        <i class="fas fa-cubes feature-icon"></i>
                        <h3 class="text-xl font-bold mb-4">细粒度对象</h3>
                    </div>
                    <p class="text-gray-700">享元模式特别适用于大量细粒度的对象，尤其是当这些对象具有大量共同的属性时。</p>
                </div>
            </div>
        </section>

        <!-- Use Cases Section -->
        <section class="mb-20">
            <h2 class="text-3xl font-bold mb-8 text-center font-serif">使用场景</h2>
            <div class="bg-white rounded-lg shadow-md overflow-hidden">
                <div class="p-8">
                    <div class="flex items-start mb-6">
                        <div class="flex-shrink-0 bg-purple-100 p-3 rounded-full mr-4">
                            <i class="fas fa-layer-group text-purple-600 text-xl"></i>
                        </div>
                        <div>
                            <h3 class="text-xl font-bold mb-2">大量细粒度对象</h3>
                            <p class="text-gray-700">当系统中存在大量细粒度的对象，并且它们之间共享一些相同的属性时，可以考虑使用享元模式。</p>
                        </div>
                    </div>
                    <div class="flex items-start">
                        <div class="flex-shrink-0 bg-blue-100 p-3 rounded-full mr-4">
                            <i class="fas fa-code-branch text-blue-600 text-xl"></i>
                        </div>
                        <div>
                            <h3 class="text-xl font-bold mb-2">状态分离</h3>
                            <p class="text-gray-700">当对象的内部状态相对稳定，而外部状态经常变化时，可以将内部状态作为共享部分，外部状态由客户端维护。</p>
                        </div>
                    </div>
                </div>
                <div class="bg-gray-50 px-8 py-6 border-t border-gray-200">
                    <h3 class="font-bold text-lg mb-3">框架中的实际应用</h3>
                    <div class="grid md:grid-cols-2 gap-4">
                        <div class="bg-blue-50 p-4 rounded-lg">
                            <h4 class="font-semibold text-blue-700 mb-2">String常量池</h4>
                            <p class="text-gray-700 text-sm">Java中的String常量池使用了享元模式，多个String对象可以共享相同的字符串字面值。</p>
                        </div>
                        <div class="bg-purple-50 p-4 rounded-lg">
                            <h4 class="font-semibold text-purple-700 mb-2">Integer缓存</h4>
                            <p class="text-gray-700 text-sm">Java中的Integer类对于-128到127之间的整数值使用了享元模式，避免了频繁创建Integer对象。</p>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Diagram Section -->
        <section class="mb-20">
            <h2 class="text-3xl font-bold mb-8 text-center font-serif">模式结构</h2>
            <div class="mermaid">
                classDiagram
                    class Flyweight {
                        +operation(extrinsicState)
                    }
                    class ConcreteFlyweight {
                        -intrinsicState
                        +operation(extrinsicState)
                    }
                    class FlyweightFactory {
                        -flyweights: Map
                        +getFlyweight(key): Flyweight
                    }
                    class Client {
                        -extrinsicState
                    }
                    Flyweight <|-- ConcreteFlyweight
                    FlyweightFactory o-- Flyweight
                    Client --> Flyweight
                    Client --> FlyweightFactory
            </div>
            <div class="mt-6 bg-white p-6 rounded-lg shadow-sm">
                <h3 class="font-bold text-lg mb-3">结构说明</h3>
                <ul class="space-y-2 text-gray-700">
                    <li><span class="font-semibold">Flyweight:</span> 定义享元对象的接口，通过该接口可以接受并作用于外部状态</li>
                    <li><span class="font-semibold">ConcreteFlyweight:</span> 实现享元接口，并为内部状态增加存储空间</li>
                    <li><span class="font-semibold">FlyweightFactory:</span> 创建并管理享元对象，确保合理地共享享元</li>
                    <li><span class="font-semibold">Client:</span> 维护对享元的引用，计算或存储享元的外部状态</li>
                </ul>
            </div>
        </section>

        <!-- Code Example Section -->
        <section class="mb-20">
            <h2 class="text-3xl font-bold mb-8 text-center font-serif">实现示例</h2>
            <div class="mb-8">
                <p class="text-gray-700 mb-6">以下是一个简单的享元模式示例，实现了一个网站管理系统，其中多个用户共享相同的网站对象：</p>
                <div class="code-block">
                    <div class="code-header">
                        <span>FlyweightPatternDemo.java</span>
                        <button class="code-copy-btn" onclick="copyCode()">
                            <i class="far fa-copy"></i> 复制代码
                        </button>
                    </div>
                    <pre class="text-gray-300 mt-4 overflow-x-auto"><code>import java.util.HashMap;
import java.util.Map;

// 网站接口
interface Website {
    void use();
}

// 具体网站类
class ConcreteWebsite implements Website {
    private String type;

    public ConcreteWebsite(String type) {
        this.type = type;
    }

    public void use() {
        System.out.println("使用 " + type + " 网站");
    }
}

// 网站工厂
class WebsiteFactory {
    private Map<String, Website> websites = new HashMap<>();

    public Website getWebsite(String type) {
        if (!websites.containsKey(type)) {
            websites.put(type, new ConcreteWebsite(type));
        }
        return websites.get(type);
    }

    public int getWebsiteCount() {
        return websites.size();
    }
}

public class FlyweightPatternDemo {
    public static void main(String[] args) {
        WebsiteFactory factory = new WebsiteFactory();

        Website blog = factory.getWebsite("博客");
        blog.use();

        Website forum = factory.getWebsite("论坛");
        forum.use();

        Website blog2 = factory.getWebsite("博客");
        blog2.use();

        System.out.println("网站数量：" + factory.getWebsiteCount());
    }
}</code></pre>
                </div>
            </div>
            <div class="bg-yellow-50 border-l-4 border-yellow-400 p-4">
                <div class="flex">
                    <div class="flex-shrink-0">
                        <i class="fas fa-lightbulb text-yellow-500 text-xl"></i>
                    </div>
                    <div class="ml-3">
                        <h3 class="text-sm font-medium text-yellow-800">设计要点</h3>
                        <div class="mt-2 text-sm text-yellow-700">
                            <p>这个示例展示了享元模式的核心思想：</p>
                            <ul class="list-disc pl-5 mt-2 space-y-1">
                                <li>通过工厂类管理共享对象</li>
                                <li>相同类型的网站对象只创建一次</li>
                                <li>外部状态由客户端维护</li>
                                <li>显著减少了对象的创建数量</li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Summary Section -->
        <section class="bg-white rounded-lg shadow-md p-8 mb-12">
            <h2 class="text-3xl font-bold mb-6 text-center font-serif">模式总结</h2>
            <div class="flex flex-col md:flex-row gap-8">
                <div class="flex-1">
                    <h3 class="text-xl font-bold mb-4 text-purple-700">优点</h3>
                    <ul class="space-y-3 text-gray-700">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>大幅减少内存中对象的数量，节省系统资源</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>通过共享机制提高系统性能</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>外部状态相对独立，不影响内部状态</span>
                        </li>
                    </ul>
                </div>
                <div class="flex-1">
                    <h3 class="text-xl font-bold mb-4 text-purple-700">缺点</h3>
                    <ul class="space-y-3 text-gray-700">
                        <li class="flex items-start">
                            <i class="fas fa-exclamation-circle text-yellow-500 mt-1 mr-2"></i>
                            <span>需要分离内部状态和外部状态，增加了系统复杂度</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-exclamation-circle text-yellow-500 mt-1 mr-2"></i>
                            <span>需要维护共享对象池，可能引入线程安全问题</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-exclamation-circle text-yellow-500 mt-1 mr-2"></i>
                            <span>不适用于所有场景，只有当大量对象共享相同状态时才有优势</span>
                        </li>
                    </ul>
                </div>
            </div>
            <div class="mt-8 p-6 bg-gray-50 rounded-lg">
                <p class="text-gray-700 leading-relaxed">
                    享元设计模式通过共享相同的内部状态来减少内存消耗，特别适用于大量细粒度的对象。通过将内部状态和外部状态分离，实现了对象的共享和重复利用。在现实世界中，享元模式可以帮助系统在维持大量对象的同时，显著减少内存占用，提高系统性能。
                </p>
            </div>
        </section>
    </div>

    <!-- Footer -->
    <footer class="bg-gray-900 text-white py-12">
        <div class="container mx-auto px-6">
            <div class="text-center">
                <h3 class="text-xl font-semibold mb-2">技术小馆</h3>
                <p class="text-gray-400 hover:text-white transition-colors">
                    <a href="http://www.yuque.com/jtostring" target="_blank">http://www.yuque.com/jtostring</a>
                </p>
                <div class="flex justify-center mt-6 space-x-4">
                    <a href="#" class="text-gray-400 hover:text-white transition-colors">
                        <i class="fab fa-github text-xl"></i>
                    </a>
                    <a href="#" class="text-gray-400 hover:text-white transition-colors">
                        <i class="fab fa-twitter text-xl"></i>
                    </a>
                    <a href="#" class="text-gray-400 hover:text-white transition-colors">
                        <i class="fab fa-linkedin text-xl"></i>
                    </a>
                </div>
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });

        function copyCode() {
            const codeElement = document.querySelector('.code-block pre code');
            const range = document.createRange();
            range.selectNode(codeElement);
            window.getSelection().removeAllRanges();
            window.getSelection().addRange(range);
            document.execCommand('copy');
            window.getSelection().removeAllRanges();
            
            const copyBtn = document.querySelector('.code-copy-btn');
            const originalHtml = copyBtn.innerHTML;
            copyBtn.innerHTML = '<i class="fas fa-check"></i> 已复制';
            
            setTimeout(() => {
                copyBtn.innerHTML = originalHtml;
            }, 2000);
        }
    </script>
</body>
</html>
```